<template>
  <div>
    <div class="list-btn">
      姓名:<Input v-model.trim="params.realname" placeholder="请输入姓名" style="width: 200px" clearable @keyup.enter.native="getList(url)" />
    </div>
    <div class="list-btn">
      手机号:<Input v-model.trim="params.phone" placeholder="请输入手机号" style="width: 200px" clearable @keyup.enter.native="getList(url)" />
    </div>
    <div class="list-btn">
      登录时间:<DatePicker type="date" @on-change="startTime"  placeholder="选择开始时间" style="width: 200px" ></DatePicker>
      ～<DatePicker type="date" @on-change="endTime"  placeholder="选择结束时间" style="width: 200px"  ></DatePicker>
    </div>
    <div class="list-btn">
      <Button type="primary" @click="getList(url,'refresh')">搜索</Button>
    </div>
    <page-list :listTitle="listTitle" :list="list" :loading="loading" @selectItem="ids = $event;"></page-list>
    <page-button :current="params.pageCurrent"  :total="total" @changePageNum="params.pageCurrent = $event; getList(url)" @changePageSize="params.pageLimit = $event; getList(url)"></page-button>
  </div>
</template>

<script>
  import listMixin from '../../mixin/list'
  import pageList from '../../template/listTemplate'
  import pageButton from '../../template/pageBtnTemplate'
  import confirmDialog from '../../template/confirmDialogTemplate'
  export default {
    mixins:[listMixin],
    components: {
      pageList,
      pageButton,
      confirmDialog
    },
    data () {
      return {
        tag: {
          'title': '登录日志',
          'path': '/work/user/vitality'
        },
        listTitle: [
          {
            title: '手机号',
            key: 'phone',
            minWidth:160,
            align:'center',
            render: (h, params) => {
              let phone = params.row.phone;
              return h('div', `${phone.substr(0,3)}****${phone.substr(7)}`)
            }
          },
          {
            title: '姓名',
            key: 'realname',
            minWidth:100,
            align:'center',
            render:(h,params) => {
              return h('div',params.row.realname ? params.row.realname  : '—')
            }
          },
          {
            title: '登录时间',
            key: 'createTime',
            minWidth:180,
            align:'center',
            render:(h,params) => {
              let time = '';
              if(params.row.createTime){
                time = this.getLocalTime(params.row.createTime)
              }
              return h('div',time)
            }
          },
         /* {
            title: '登录次数',
            key: 'loginTimes',
            align:'center',
            minWidth:100,
          },*/
          {
            title: '登录IP',
            key: 'ip',
            align:'center',
            minWidth:180,
            render:(h,params) => {
              return h('div',params.row.ip ? params.row.ip : '—')
            }

          },
        ],
        url: '/userlogin/list',
        nameListUrl: '',
        params: {
          pageCurrent: 1,
          pageLimit: 10
        },

      }
    },
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .list-btn{
    margin-bottom: 5px;
    margin-right: 5px;
    display: inline-block;
  }
  .refresh-btn{
    float: right;
  }

</style>



